package dao;

import java.io.Serializable;
import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.TypedQuery;

import entity.Role;

@JPA
@Stateless
public class JPARoleDAO extends GenericJPADAO<Role> implements RoleDAO, Serializable {

	@Override
	public Role selectRoleByName(String name) {
		TypedQuery<Role> query = em.createNamedQuery("Role.selectByName", Role.class).setParameter("name", name);
		Role res = query.getSingleResult();
		return res;
	}
	
	@Override
	public List<String> selectRoleNames() {
		TypedQuery<String> query = em.createNamedQuery("Role.selectNames", String.class);
		List<String> res = query.getResultList();
		return res;
	}
	
}
